package com.jdrx.sw.sewage.api.app;

import com.jdrx.platform.commons.rest.beans.vo.ResponseVO;
import com.jdrx.platform.commons.rest.factory.ResponseFactory2;
import com.jdrx.sw.sewage.beans.dto.DnbThanSurfaceDTO;
import com.jdrx.sw.sewage.beans.dto.StationIdDTO;
import com.jdrx.sw.sewage.beans.dto.WaterCodQualityQueryDTO;
import com.jdrx.sw.sewage.beans.dto.WaterYieldQueryDTO;
import com.jdrx.sw.sewage.beans.vo.DnbSurfaceVO;
import com.jdrx.sw.sewage.beans.vo.ReportAnalysisVO;
import com.jdrx.sw.sewage.common.constant.Constant;
import com.jdrx.sw.sewage.service.StationReportAnalysisServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(value = "/api/app/dataanalysis")
@Api(value = "app-数据分析")
public class DataAnalysisAppApi {
    @Autowired
    private StationReportAnalysisServiceImpl reportAnalysisServiceImpl;

    @ApiOperation(value = "进出水量分析")
    @RequestMapping(value = "selectInAndOutWaterYield", method = RequestMethod.POST)
    public ResponseVO<Map<LocalDateTime, List<ReportAnalysisVO>>> selectInAndOutWaterYield(@RequestHeader(Constant.DATA_NODE) String dataNode,
                                                                                           @RequestHeader(Constant.TENANT_ID) String tenantId,
                                                                                           @RequestBody WaterYieldQueryDTO waterYieldQueryDTO) {
        return ResponseFactory2.ok(reportAnalysisServiceImpl.selectInAndOutWaterYield(waterYieldQueryDTO));
    }

    @ApiOperation(value = "能耗分析-数据分析")
    @RequestMapping(value = "selectDnbSurface", method = RequestMethod.POST)
    public ResponseVO<List<ReportAnalysisVO>> selectDnbSurface(@RequestHeader(Constant.DATA_NODE) String dataNode,
                                                               @RequestHeader(Constant.TENANT_ID) String tenantId,
                                                               @RequestBody WaterYieldQueryDTO waterYieldQueryDTO) {
        return ResponseFactory2.ok(reportAnalysisServiceImpl.selectDnbSurface(waterYieldQueryDTO));
    }

    @ApiOperation(value = "总能耗比-数据分析")
    @RequestMapping(value = "selectDnbThanSurface", method = RequestMethod.POST)
    public ResponseVO<List<DnbSurfaceVO>> selectDnbThanSurface(@RequestHeader(Constant.DATA_NODE) String dataNode,
                                                               @RequestHeader(Constant.TENANT_ID) String tenantId,
                                                               @RequestBody DnbThanSurfaceDTO dnbThanSurfaceDTO) {
        return ResponseFactory2.ok(reportAnalysisServiceImpl.selectDnbThanSurface(dnbThanSurfaceDTO));
    }

    @ApiOperation(value = "出水水质-数据分析")
    @RequestMapping(value = "selectWaterCodQuality", method = RequestMethod.POST)
    public ResponseVO<Map<Integer, List<ReportAnalysisVO>>> selectWaterCodQuality(@RequestHeader(Constant.DATA_NODE) String dataNode,
                                                                                  @RequestHeader(Constant.TENANT_ID) String tenantId,
                                                                                  @RequestBody WaterCodQualityQueryDTO waterCodQualityQueryDTO) {
        return ResponseFactory2.ok(reportAnalysisServiceImpl.selectWaterCodQuality(waterCodQualityQueryDTO));
    }

    @ApiOperation(value = "出水水质点查询-数据分析")
    @RequestMapping(value = "selectWaterQualityPoint", method = RequestMethod.POST)
    public ResponseVO<List<String>> selectWaterQualityPoint(@RequestHeader(Constant.DATA_NODE) String dataNode,
                                                            @RequestHeader(Constant.TENANT_ID) String tenantId,
                                                            @RequestBody @Valid StationIdDTO dto) {
        return ResponseFactory2.ok(reportAnalysisServiceImpl.selectWaterQualityPoint(dto));
    }
}
